#ifndef TEXT_HEADER
#define TEXT_HEADER

// this header needs
#include <stdio.h>
#include "../FILE.h"

// text_t enum
// enum with supported 
// text file types
typedef enum
{
  TEXT_NO_TYPE,
  TEXT_CSV,
} text_t;

// text_err_cd enum
// enum with general error 
// codes for a text file
typedef enum
{
  TEXT_ERR_NO_ERR, // file has no errors
  // ...
  /**********/
  TEXT_ERR_LN, // errors below this (in numeric value) are non-fatal, above are fatal
  /**********/
  TEXT_ERR_UNKNOWN_ENC,
  TEXT_ERR_NULL_PATH,
  // ...
} text_err_cd;

// text_enc enum
// enum with supported 
// text file encoding types
typedef enum
{
  TEXT_ENC_UNKNOWN, // encoding is unsupported
  TEXT_ENC_ASCII,
  TEXT_ENC_CP1252,
  TEXT_ENC_CP932,
  TEXT_ENC_SHIFT_JIS,
  TEXT_ENC_UTF8,
  TEXT_ENC_UTF16BE,
  TEXT_ENC_UTF16LE,
  TEXT_ENC_END_INT, // not an encoding
} text_enc;

// text general structure 
typedef struct
{
  char * PATH;            // extra information I want to be able to see
  byte * DATA;            // the bytes of the file loaded in memory
  umax SIZE;              // size is very variable on text files
  text_enc ENC;           // text file encoding
  text_err_cd ERR_CD_INC; // error code from check_text_inc()
  text_t TYPE;            // text file type
  text_err_cd ERR_CD_TP;  // error code from a text file type function (reuses the text_err_cd type)
  void * ST;              // pointer to the text structure (specific to each type of text file)
} text;

// text_data_t enum
// enum with text file data types
typedef enum
{
  TEXT_UINT,      // unsigned integer
  TEXT_SINT,      // signed integer
  TEXT_FLOAT,     // floating point number
  TEXT_CHAR_ARR,  // character array (fixed size)
  TEXT_STR,       // string (until some character)
} text_data_t;

// build, close and print an incomplete text structure (a complete build
// will have to be made by more file type specific functions)
text_enc check_text_enc(char * text_file_path);
text_err_cd check_text_inc(char * text_file_path);
text * open_text_inc(char * text_file_path);
void close_text_inc(text * text_file);
void print_text_inc(text * text_file);

// other functions
bool insert_text_chars(text * txt_f, void * txt_pos, umax * chints, umax csize);
bool remove_text_chars(text * txt_f, void * txt_pos, umax rm_size);

#include "TEXT.c"

#endif // TEXT_HEADER
